package com.ruoyi.project.bajiaostar.tGoodDetail.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.bajiaostar.tGoodDetail.domain.TGoodDetail;
import com.ruoyi.project.bajiaostar.tGoodDetail.service.ITGoodDetailService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 商品详情信息Controller
 * 
 * @author wangwu
 * @date 2024-05-21
 */
@Controller
@RequestMapping("/bajiaostar/tGoodDetail")
public class TGoodDetailController extends BaseController
{
    private String prefix = "bajiaostar/tGoodDetail";

    @Autowired
    private ITGoodDetailService tGoodDetailService;

    @RequiresPermissions("bajiaostar:tGoodDetail:view")
    @GetMapping()
    public String tGoodDetail()
    {
        return prefix + "/tGoodDetail";
    }

    /**
     * 查询商品详情信息列表
     */
    @RequiresPermissions("bajiaostar:tGoodDetail:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TGoodDetail tGoodDetail)
    {
        startPage();
        List<TGoodDetail> list = tGoodDetailService.selectTGoodDetailList(tGoodDetail);
        return getDataTable(list);
    }

    /**
     * 导出商品详情信息列表
     */
    @RequiresPermissions("bajiaostar:tGoodDetail:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TGoodDetail tGoodDetail)
    {
        List<TGoodDetail> list = tGoodDetailService.selectTGoodDetailList(tGoodDetail);
        ExcelUtil<TGoodDetail> util = new ExcelUtil<TGoodDetail>(TGoodDetail.class);
        return util.exportExcel(list, "tGoodDetail",null);
    }

    /**
     * 新增商品详情信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存商品详情信息
     */
    @RequiresPermissions("bajiaostar:tGoodDetail:add")
    @Log(title = "商品详情信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TGoodDetail tGoodDetail)
    {
        return toAjax(tGoodDetailService.insertTGoodDetail(tGoodDetail));
    }

    /**
     * 修改商品详情信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TGoodDetail tGoodDetail = tGoodDetailService.selectTGoodDetailById(id);
        mmap.put("tGoodDetail", tGoodDetail);
        return prefix + "/edit";
    }

    /**
     * 修改保存商品详情信息
     */
    @RequiresPermissions("bajiaostar:tGoodDetail:edit")
    @Log(title = "商品详情信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TGoodDetail tGoodDetail)
    {
        return toAjax(tGoodDetailService.updateTGoodDetail(tGoodDetail));
    }

    /**
     * 删除商品详情信息
     */
    @RequiresPermissions("bajiaostar:tGoodDetail:remove")
    @Log(title = "商品详情信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tGoodDetailService.deleteTGoodDetailByIds(ids));
    }
}
